<cpanel include="../config.php">
<?

/***************************************************************************
 *                                 status.php
 *                            -------------------
 *   Begin                : Monday, May 2, 2005
 *   Copyright            : (C) 2005 Point and Code
 *   Domain               : http://www.pointandcode.com/
 *   Email                : support@pointandcode.com
 *   Version              : 1.0.1
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

// Set some variables
$html_root_path = '../';

// Include some pages
include $root_path.'common.php';
$page_title = $lang['service_status'];
include $root_path.'page_header.php';


$service_status_data = "<cpanel Serverinfo="servicestatus()">";

$uptime = "<cpanel uptime="">";


//
// Get rid of the end tags - we're splitting by start.
//
$service_status_data = str_replace('<tr>', '', $service_status_data);
$service_status_data = str_replace('<td>', '', $service_status_data);

//
// Let's split it up into rows and items
//
$array_by_rows = explode('</tr>', $service_status_data);


$service_status_array = array();


$i=0;
foreach($array_by_rows as $row) {

	$array_by_cols = explode('</td>', $row);
	$name = str_replace("\n", '', $array_by_cols[0]);
	if (!empty($name)) {
		$service_status_array[$i]['name'] = $name;
		$service_status_array[$i]['status'] = $array_by_cols[1];
		$service_status_array[$i]['dot'] = $array_by_cols[2];
		
		//
		// Changes the status image files to a colour name
		//
		switch($service_status_array[$i]['dot']) {
			case '<img src=/green-status.gif>':
				$service_status_array[$i]['status_brief'] = 'Green';
				break;
			case '<img src=/yellow-status.gif>':
				$service_status_array[$i]['status_brief'] = 'Yellow';
				break;
			case '<img src=/red-status.gif>':
				$service_status_array[$i]['status_brief'] = 'Red';
				break;
		}
		$service_status_array[$i]['status_image'] = strtolower($service_status_array[$i]['status_brief']).'-status.gif';
		
		//
		// incrememnts counter
		//
		$i++;
	}
}




//
// The parsing is complete!
//




$template->set_filenames(array(
	'body' => $root_path.$template_path.'status.tpl')
);

$i = 0;

foreach ($service_status_array as $row) {

	
	$template->assign_block_vars('statusrow', array(
		'ROWCLASS' => ($i%2) ? $template_cfg['class_row_1'] : $template_cfg['class_row_2'],
		'NAME' => $row['name'],
		'STATUS' => $row['status'],
		'STATUS_BRIEF' => $row['status_brief'],
		'I_STATUS' => '<img src="'.$html_root_path.$template_path.'images/'.$row['status_image'].'">'
		)
	);
$i++;	
}

$template->assign_vars(array(
	'UPTIME' => $uptime,
	
	'L_SERVICE_STATUS_INTRO' => $lang['service_status_intro'],
	'L_SERVICE_STATUS' => $lang['service_status'],
	'L_UPTIME' => $lang['uptime'],
	'L_PROCESS' => $lang['process'],
	'L_STATUS' => $lang['status'],
));

$template->pparse('body');


?>

<cpanel include="../page_tail.php">